import ImgPreview from './index.vue'

import vue from 'vue'

const ImgPreviewClass = vue.extend(ImgPreview)
const instance = new ImgPreviewClass()

export default {
  name: 'ImgPreview',

  show(config) {
    const { imgSrc, description } = config
    instance.$mount(document.createElement('div'))
    document.body.appendChild(instance.$el)
    instance.imgSrc = imgSrc
    instance.description = description
    this.stop()
  },

  // 禁止页面滑动
  stop() {
    const mo = function(e) {
      e.preventDefault()
    }
    document.body.style.overflow = 'hidden'
    document.addEventListener('touchmove', mo, false)
  }
}
